import torch

# add
a = torch.rand(2, 3)
b = torch.rand(2, 3)
print("a =", a)
print("b =", b)
print("a + b =", a + b)
print("a + b =", a.add(b))
print("a + b =", torch.add(a, b))
print("a =", a)
print("a + b =", a.add_(b))
print("a =", a)

# 取整、取余
a = torch.rand(2, 2)
a = a * 10
print("a =", a)
print("torch.floor(a)=", torch.floor(a)) # 向下
print("torch.ceil(a)=", torch.ceil(a)) # 向上
print("torch.round(a)=", torch.round(a)) # 四舍五入
print("torch.trunc(a)=", torch.trunc(a)) # 取整数部分
print("torch.frac(a)=", torch.frac(a)) # 取小数部分
print("a % 2=", a % 2)

